				//---public color schemes
					var ad_color_schemes = [
						{id: "sys1",	name: "初始",	title: "0000FF",	desc: "000000",	link: "008000",	border: "E6E6E6",	bg: "FFFFFF",	ctbg: "FFFFFF",	bgpic: 0,	corner: 0,	icon:0},
						{id: "sys2",	name: "经典白",	title: "0044DD",	desc: "275689",	link: "C1C1C1",	border: "E1E1E1",	bg: "FFFFFF",	ctbg: "FFFFFF",	bgpic: 0,	corner: 10,	icon:0},
						{id: "sys3",	name: "天空蓝",	title: "37499C",	desc: "5892CB",	link: "5768AC",	border: "D6E9FC",	bg: "EDF9F7",	ctbg: "FFFFFF",	bgpic: 0,	corner: 10,	icon:1},
						{id: "sys4",	name: "木纹灰",	title: "000000",	desc: "6A6A6A",	link: "373737",	border: "E1E1E1",	bg: "FFFFFF",	ctbg: "FFFFFF",	bgpic: 1,	corner: 10,	icon:2},
						{id: "sys5",	name: "素色花",	title: "225CAE",	desc: "4B6584",	link: "4374BA",	border: "E1E4F5",	bg: "FFFFFF",	ctbg: "FFFFFF",	bgpic: 2,	corner: 6,	icon:0},
						{id: "sys6",	name: "典雅绿",	title: "FFFB88",	desc: "FFFFFF",	link: "FFFB88",	border: "007D18",	bg: "FFFFFF",	ctbg: "FFFFFF",	bgpic: 8,	corner: 8,	icon:1},
					];
				//---
				function load_color_scheme(scheme_id) {
					s = false;
					for (i=0;i<ad_color_schemes.length;i++) {
						if (!ad_color_schemes[i]) continue;
						if (ad_color_schemes[i].id == scheme_id) {
							s=ad_color_schemes[i];
							break;
						}
					}
					if (!s) return false;
					opts = jQuery("#ad_color_schemes_sel").get(0).options;
					
					for(i=0;i<opts.length;i++) {
						if (opts[i].value == scheme_id) opts[i].selected = true;
						else opts[i].selected = false;
					}
					jQuery("#ad_text_color").get(0).value = "#"+s.title;
					jQuery("#ad_desc_color").get(0).value = "#"+s.desc;
					jQuery("#ad_link_color").get(0).value = "#"+s.link;
					jQuery("#ad_border_color").get(0).value = "#"+s.border;
					jQuery("#ad_bg_color").get(0).value = "#"+s.bg;
					jQuery("#ad_ctbg_color").get(0).value = "#"+s.ctbg;
					jQuery("#ad_bg_pic").get(0).value = s.bgpic;
					jQuery("#ad_corner").get(0).value = s.corner;
					jQuery("input[@name='ad_status_icon']").each(function(){
						if (this.value == s.icon) this.checked = true;
						else this.checked = false;
					});
					ad_gen_code();
				}
				function ad_create_scheme_list() {
					selsys = jQuery("#ad_color_schemes_sys");
					selsys.get(0).innerHTML = '';
					selusr = jQuery("#ad_color_schemes_usr");
					selusr.get(0).innerHTML = '';
					for(i=0;i<ad_color_schemes.length;i++) {
						if (!ad_color_schemes[i]) continue;
						temps = ad_color_schemes[i].id;
						if (temps.substr(0,3) == 'sys') {
							selsys.append("<option value=\""+ad_color_schemes[i].id+"\">"+ad_color_schemes[i].name+"</option>");
						} else {
							selusr.show();
							selusr.append("<option value=\""+ad_color_schemes[i].id+"\">"+ad_color_schemes[i].name+"</option>");
						}
					}
				}
				function ad_change_color_scheme() {
					v = jQuery("#ad_color_schemes_sel").get(0).value;
					if (v != 'custom') {
						load_color_scheme(v);
					} else {
						//here
					}
				}
				function ad_color_schemes_custom() {
					jQuery("#ad_color_schemes_sel").get(0).value = 'custom';
					ad_change_color_scheme();
				}
			
			
				function ad_color_code(code) {
					rtn=code.substr(1);
					return rtn;
				}
				function get_ad_status_icon_value() {
					valll = 0;
					jQuery("input[@name='ad_status_icon']").each(function(){
						if (this.checked == true) {valll = this.value;}
					});
					return valll;

				}
				function ad_size_type(typeid) {
					var rtn;
					switch (typeid) {
						case "11":
							rtn={width:760,height:90};
							break;
						case "12":
							rtn={width:468,height:60};
							break;
						case "13":
							rtn={width:250,height:60};
							break;
						case "14":
							rtn={width:728,height:90};
							break;
						case "15":
							rtn={width:950,height:90};
							break;
						case "21":
							rtn={width:120,height:600};
							break;
						case "22":
							rtn={width:120,height:240};
							break;
						case "23":
							rtn={width:160,height:600};
							break;
						case "31":
							rtn={width:180,height:250};
							break;
						case "32":
							rtn={width:250,height:300};
							break;
						case "33":
							rtn={width:360,height:190};
							break;
						case "34":
							rtn={width:250,height:250};
							break;
						case "35":
							rtn={width:200,height:200};
							break;
						case "36":
							rtn={width:336,height:280};
							break;
						case "37":
							rtn={width:300,height:250};
							break;
						case "41":
							rtn={width:120,height:60};
							break;
					}
					return rtn;
				}
				function ad_make_round_corner(size,bgcolor,width,bordercolor) {
					for (i=1;i<=10;i++) {
						if (size >= (i-1)) {
							bc = Math.round(size - Math.sqrt(Math.pow(size,2)-Math.pow((size-i),2)));
							if (!bc) bc = 0;
							ww = width - 2*bc;
						} else {
							bc = 0;
							ww = width;
						}
						if (!bc) bc=0;
						if (!ww) ww=width;
						newww = ww;
						if (bc == 1) {
							borderstring = "1px solid " + bgcolor;
							innerborderstring = "0";
							widthstring = ww+"px";
							innerwidthstring = "0";
						} else {
							if (bc >0) bc -= 1;
							if (bc == 0) {
								borderstring = "0";
								innerborderstring = "0";
							} else {
								borderstring = bc + "px solid " + bgcolor;
								innerborderstring = "1px solid " + bordercolor;
								newww = ww+2;
							}
							if (newww >= width) {
								widthstring = "0";
								innerwidthstring = "0";
							} else {
								widthstring = newww+"px";
								innerwidthstring = ww+"px";
							}
						}
						jQuery("#ad-corner-t"+i).css({
							borderLeft: borderstring,
							borderRight: borderstring,
							width: widthstring
						});
						jQuery("#ad-corner-inner-t"+i).css({
							borderLeft: innerborderstring,
							borderRight: innerborderstring,
							width: innerwidthstring
						});
						
						jQuery("#ad-corner-b"+i).css({
							borderLeft: borderstring,
							borderRight: borderstring,
							width: widthstring
						});
						jQuery("#ad-corner-inner-b"+i).css({
							borderLeft: innerborderstring,
							borderRight: innerborderstring,
							width: innerwidthstring
						});
					}
				}
				function ad_preview_it() {
					jQuery(".ad_color_field").each (function(){
						jQuery(this).css('background-color',this.value);
					});
					jQuery("#ad_bg_pic_show")[0].src=alimama_deluxe_pluginurl+"/images/bg"+jQuery("#ad_bg_pic").get(0).value+".gif";
					jQuery("#ad_corner_show")[0].src=alimama_deluxe_pluginurl+"/images/zj"+jQuery("#ad_corner").get(0).value+".gif";
					sized = ad_size_type(jQuery("#ad_size_code").get(0).value);
					jQuery("#ad-container").css({
						width: sized.width,
						height: sized.height,
						backgroundColor: jQuery("#ad_ctbg_color").get(0).value
					});
					jQuery("#ad-bg").css({
						width: sized.width,
						height: sized.height,
						backgroundColor: jQuery("#ad_bg_color").get(0).value
					});
					tempo = jQuery("#ad_bg_pic").get(0).value;
					if (tempo>0) {
						imageurl = alimama_deluxe_pluginurl+"/images/bg"+tempo+".gif";
						jQuery("#ad-bg").css({backgroundImage: "url("+imageurl+")"});
					} else {
						jQuery("#ad-bg").css({backgroundImage: ""});
					}
					p_pos = jQuery("#ad-bg").position();
					jQuery("#ad-corner-top-ct").css({top:p_pos.top+"px",left:p_pos.left+"px",width:sized.width+"px"});
					jQuery("#ad-corner-bottom-ct").css({top:(p_pos.top+sized.height-10)+"px",left:p_pos.left+"px",width:sized.width+"px"});
					tempo = jQuery("#ad_corner").get(0).value;
						ad_make_round_corner(tempo,jQuery("#ad_ctbg_color").get(0).value,sized.width,jQuery("#ad_border_color").get(0).value);
						jQuery("#ad-corner-top-ct").show();
						jQuery("#ad-corner-bottom-ct").show();
					tmpClsName = sized.width + "x" + sized.height;
					switch (jQuery("#ad_size_code").get(0).value) {
						case '11':
						case '12':
						case '14':
						case '15':
							tbstr = "<table id=\"ad-content-table\"><tr><td width=\"60%\">";
							tbstr += "<div id=\"ad-title\" class=\"t"+tmpClsName+"\">Alimama Deluxe 广告预览</div>";
							tbstr += "<div id=\"ad-link\" class=\"l"+tmpClsName+"\">www.wordpresscn.com</div>";
							tbstr += "</td><td>";
							tbstr += "<div id=\"ad-des\" class=\"d"+tmpClsName+"\">Alimama Deluxe，WordPress 上最好的 Alimama 广告发布插件。</div>";
							tbstr += "</td></tr></table>";
							break;
						case '13':
						case '21':
						case '22':
						case '23':
						case '31':
						case '32':
						case '33':
						case '34':
						case '35':
						case '36':
						case '37':
						case '41':
							tbstr = "<table id=\"ad-content-table\"><tr><td>";
							tbstr += "<div id=\"ad-title\" class=\"t"+tmpClsName+"\">Alimama Deluxe 广告预览</div>";
							tbstr += "<div id=\"ad-des\" class=\"d"+tmpClsName+"\">WP最好的 Alimama 广告发布插件</div>";
							tbstr += "<div id=\"ad-link\" class=\"l"+tmpClsName+"\">www.wordpresscn.com</div>";
							tbstr += "</td></tr></table>";
							break;
					}
					jQuery("#ad-content").get(0).innerHTML = tbstr;
					jQuery("#ad-content").css({width:sized.width-12,height:sized.height-12,border:"1px solid "+jQuery("#ad_border_color").get(0).value,padding: "5px"});
					jQuery("#ad-title").css('color',jQuery("#ad_text_color").get(0).value);
					jQuery("#ad-des").css('color',jQuery("#ad_desc_color").get(0).value);
					jQuery("#ad-link").css('color',jQuery("#ad_link_color").get(0).value);
					
					obj = jQuery("#ad-alimama-icon");
					obj.css({
						top: p_pos.top+sized.height-17,
						left: p_pos.left+sized.width-107
					});
					tempo = get_ad_status_icon_value();
					image_filename = alimama_deluxe_pluginurl+"/images/alimama"+tempo+".png";
					if (navigator.appVersion.match(/MSIE [0-6]\./)) {
						obj.css({
						backgroundImage: 'none',
						filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image_filename + "')"
						});
					} else {
						obj.css({backgroundImage: "url("+image_filename+")"});
					}
					
				}
				function ad_gen_code() {
					var js = "<"+"script type=\"text/JavaScript\""+">\n";
					js +=	"alimama_pid=\""+jQuery("#alimama-pid").get(0).value+"\";\n"; 
					js +=	"alimama_titlecolor=\""+ad_color_code(jQuery('#ad_text_color').get(0).value)+"\";\n";
					js +=	"alimama_descolor=\""+ad_color_code(jQuery('#ad_desc_color').get(0).value)+"\";\n";
					js +=	"alimama_bgcolor=\""+ad_color_code(jQuery('#ad_bg_color').get(0).value)+"\";\n";
					js +=	"alimama_bordercolor=\""+ad_color_code(jQuery('#ad_border_color').get(0).value)+"\";\n";
					js +=	"alimama_linkcolor=\""+ad_color_code(jQuery('#ad_link_color').get(0).value)+"\";\n";
					js +=	"alimama_bottomcolor=\""+ad_color_code(jQuery('#ad_ctbg_color').get(0).value)+"\";\n";
					js +=	"alimama_anglesize=\""+jQuery('#ad_corner').get(0).value+"\";\n"; 
					js +=	"alimama_bgpic=\""+jQuery('#ad_bg_pic').get(0).value+"\";\n"; 
					js +=	"alimama_icon=\""+get_ad_status_icon_value()+"\";\n"; 
					js +=	"alimama_sizecode=\""+jQuery('#ad_size_code').get(0).value+"\";\n"; 
					js +=	"alimama_width="+jQuery('#ad_size_width').get(0).value+";\n"; 
					js +=	"alimama_height="+jQuery('#ad_size_height').get(0).value+";\n"; 
					js +=	"alimama_type="+jQuery('#ad_ad_type').get(0).value+";\n"; 
					js +=	"<"+"/script>\n";
					js +=	"<"+"script src=\"http://a.alimama.cn/inf.js\" type=text/javascript>\n";
					js +=	"<"+"/script>\n";
					jQuery("#alimama-deluxe-js-code").get(0).value = js;
					jQuery("#ad_alimama_deluxe_js_code").get(0).value = js;
					var ad_color_scheme_name = jQuery('#ad_color_schemes_sel').get(0).value;
					var ad_color_scheme_detail = {
							id: ad_color_scheme_name,
							name: '自定义',
							title: ad_color_code(jQuery('#ad_text_color').get(0).value),
							desc: ad_color_code(jQuery('#ad_desc_color').get(0).value),
							link: ad_color_code(jQuery('#ad_link_color').get(0).value),
							border: ad_color_code(jQuery('#ad_border_color').get(0).value),
							bg: ad_color_code(jQuery('#ad_bg_color').get(0).value),
							ctbg: ad_color_code(jQuery('#ad_ctbg_color').get(0).value),
							bgpic: jQuery('#ad_bg_pic').get(0).value,
							corner: jQuery('#ad_corner').get(0).value,
							icon:get_ad_status_icon_value()
						};
					jQuery("input[@name='alimama_deluxe_color_scheme_name']").get(0).value = ad_color_scheme_name;
					jQuery("input[@name='alimama_deluxe_color_scheme_detail']").get(0).value = JSON.stringify(ad_color_scheme_detail);
					ad_preview_it();
				}
				function load_code_settings(edit_ad) {
					var code = jQuery("#alimama-deluxe-js-code").get(0).value;
					regex = /(alimama_.+?)\s*=\s*"?(.+?)"?\s*;/g;
					regex2 = /(alimama_.+?)\s*=\s*"?(.+?)"?\s*;/;
					m = code.match(regex);
					if (m && m.length) {
						for(i=1;i<m.length;i++) {
							m2 = m[i].match(regex2);
							switch(m2[1]) {
								case 'alimama_pid':
									if (edit_ad) jQuery("#alimama-pid").get(0).value = m2[2];
									break;
								case 'alimama_sizecode':
									if (edit_ad) {
										jQuery("#ad_size_code").get(0).value = m2[2];
										var tempd = ad_size_type(m2[2]);
										jQuery("#ad_size_width").get(0).value = tempd.width;
										jQuery("#ad_size_height").get(0).value = tempd.height;
									}
									break;
								case 'alimama_pid':
									if (edit_ad) jQuery("#ad_ad_type").get(0).value = m2[2];
									break;
								case 'alimama_descolor':
									jQuery("#ad_desc_color").get(0).value = "#"+m2[2];
									break;
								case 'alimama_bgcolor':
									jQuery("#ad_bg_color").get(0).value = "#"+m2[2];
									break;
								case 'alimama_titlecolor':
									jQuery("#ad_text_color").get(0).value = "#"+m2[2];
									break;
								case 'alimama_bordercolor':
									jQuery("#ad_border_color").get(0).value = "#"+m2[2];
									break;
								case 'alimama_linkcolor':
									jQuery("#ad_link_color").get(0).value = "#"+m2[2];
									break;
								case 'alimama_bottomcolor':
									jQuery("#ad_ctbg_color").get(0).value = "#"+m2[2];
									break;
								case 'alimama_anglesize':
									jQuery("#ad_corner").get(0).value = m2[2];
									break;
								case 'alimama_bgpic':
									jQuery("#ad_bg_pic").get(0).value = m2[2];
									break;
								case 'alimama_icon':
									jQuery("input[@name='ad_status_icon']").each(function(){
										if (this.value == m2[2]) {
											this.checked = true;
										} else {
											this.checked = false;
										}
									});
									break;
							}
						}
					}
					ad_gen_code();
				}
				function ad_color_onclick(id) {
					ad_close_color_pattern();
					var obj = jQuery(id);
					if (!obj) rtn=false;
					var pos = obj.position();
					var width = obj.width();
					var dest = jQuery("#ad-float-div");
					dest.hide();
					var newtop = pos.top + "px";
					var newleft = pos.left + width + 10;
					newleft += "px";
					dest.css("left",newleft);
					dest.css("top",newtop);
					fb = jQuery.farbtastic("#ad-float-div-color");
					fb.linkTo(function(){
						obj.get(0).value = fb.color;
						obj.css({
							backgroundColor: fb.color,
							color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
						});
						//fb.callback = obj;
						ad_color_schemes_custom();
						ad_gen_code();
						
					});
					fb.setColor(obj.get(0).value);
					obj.bind('keyup',function(){
						//valid color
						mg = /^#[0-9a-fA-F]{0,6}$/;
						if (!this.value.match(mg)) this.value = fb.color;
						if (fb.color && fb.color != this.value) {
							fb.setColor(this.value);
						}
					});
					dest.show();
					
				}
				function ad_close_color_pattern() {
						var obj=jQuery("#ad-float-div");
						obj.unbind();
						obj.hide();
				}
				function alimama_deluxe_write_preview_html(previewdiv) {
					var pre_code = '<h3>文字广告样式，如果您使用图片广告，您可以忽略以下设定</h3><div id="ad-container"><div id="ad-bg">';
					pre_code += '<div id="ad-corner-top-ct">';
					pre_code += '<div id="ad-corner-t1" class="ad-corner-strip"><div id="ad-corner-inner-t1"></div></div>';
					pre_code += '<div id="ad-corner-t2" class="ad-corner-strip"><div id="ad-corner-inner-t2"></div></div>';
					pre_code += '<div id="ad-corner-t3" class="ad-corner-strip"><div id="ad-corner-inner-t3"></div></div>';
					pre_code += '<div id="ad-corner-t4" class="ad-corner-strip"><div id="ad-corner-inner-t4"></div></div>';
					pre_code += '<div id="ad-corner-t5" class="ad-corner-strip"><div id="ad-corner-inner-t5"></div></div>';
					pre_code += '<div id="ad-corner-t6" class="ad-corner-strip"><div id="ad-corner-inner-t6"></div></div>';
					pre_code += '<div id="ad-corner-t7" class="ad-corner-strip"><div id="ad-corner-inner-t7"></div></div>';
					pre_code += '<div id="ad-corner-t8" class="ad-corner-strip"><div id="ad-corner-inner-t8"></div></div>';
					pre_code += '<div id="ad-corner-t9" class="ad-corner-strip"><div id="ad-corner-inner-t9"></div></div>';
					pre_code += '<div id="ad-corner-t10" class="ad-corner-strip"><div id="ad-corner-inner-t10"></div></div>';
					pre_code += '</div>';
					pre_code += '<div id="ad-content"></div>';
					pre_code += '<div id="ad-alimama-icon"></div>';
					pre_code += '<div id="ad-corner-bottom-ct">';
					pre_code += '<div id="ad-corner-b10" class="ad-corner-strip"><div id="ad-corner-inner-b10"></div></div>';
					pre_code += '<div id="ad-corner-b9" class="ad-corner-strip"><div id="ad-corner-inner-b9"></div></div>';
					pre_code += '<div id="ad-corner-b8" class="ad-corner-strip"><div id="ad-corner-inner-b8"></div></div>';
					pre_code += '<div id="ad-corner-b7" class="ad-corner-strip"><div id="ad-corner-inner-b7"></div></div>';
					pre_code += '<div id="ad-corner-b6" class="ad-corner-strip"><div id="ad-corner-inner-b6"></div></div>';
					pre_code += '<div id="ad-corner-b5" class="ad-corner-strip"><div id="ad-corner-inner-b5"></div></div>';
					pre_code += '<div id="ad-corner-b4" class="ad-corner-strip"><div id="ad-corner-inner-b4"></div></div>';
					pre_code += '<div id="ad-corner-b3" class="ad-corner-strip"><div id="ad-corner-inner-b3"></div></div>';
					pre_code += '<div id="ad-corner-b2" class="ad-corner-strip"><div id="ad-corner-inner-b2"></div></div>';
					pre_code += '<div id="ad-corner-b1" class="ad-corner-strip"><div id="ad-corner-inner-b1"></div></div>';
					pre_code += '</div></div></div>';
					jQuery(previewdiv).html(pre_code);
				}
			function alimama_deluxe_write_control_html(controldiv) {
				var pre_code = '<div id="ad-control">';
				pre_code += '<div id="ad-float-div" tag="none" style="display:none;"><div id="ad-float-div-color"></div><span id="ad-float-div-close" onclick="ad_close_color_pattern();">X</span></div>';
				pre_code += '<table width="98%">';
				pre_code += '<tr>';
				pre_code += '	<td colspan="4">';
				pre_code += '	配色方案：<select id="ad_color_schemes_sel" onchange="ad_change_color_scheme()">';
				pre_code += '					<optgroup id="ad_color_schemes_sys" label="系统配色方案"></optgroup>';
				pre_code += '					<optgroup id="ad_color_schemes_usr" label="用户配色方案" style="display:none"></optgroup>';
				pre_code += '					<option value="custom">自定义</option>';
				pre_code += '				</select>';
				pre_code += '	</td>';
				pre_code += '</tr>';
				pre_code += '<tr>';
				pre_code += '	<td>';
				pre_code += '		<p><label>标题：</label><input type="text" class="ad_color_field ad_canmodi_item" size="7" maxlength="7" name="ad_text_color" id="ad_text_color" value="#123456" /></p>';
				pre_code += '		<p><label>描述：</label><input type="text" class="ad_color_field ad_canmodi_item" size="7" name="ad_desc_color" id="ad_desc_color" value="#123456" /></p>';
				pre_code += '		<p><label>链接：</label><input type="text" class="ad_color_field ad_canmodi_item" size="7" name="ad_link_color" id="ad_link_color" value="#123456" /></p>';
				pre_code += '	</td>';
				pre_code += '	<td>';
				pre_code += '		<p><label>边框：</label><input type="text" class="ad_color_field ad_canmodi_item" size="7" name="ad_border_color" id="ad_border_color" value="#123456" /></p>';
				pre_code += '		<p><label>背景：</label><input type="text" class="ad_color_field ad_canmodi_item" size="7" name="ad_bg_color" id="ad_bg_color" value="#123456" /></p>';
				pre_code += '		<p><label>底色：</label><input type="text" class="ad_color_field ad_canmodi_item" size="7" name="ad_ctbg_color" id="ad_ctbg_color" value="#123456" /></p>';
				pre_code += '	</td>';
				pre_code += '	<td>';
				pre_code += '		<p><label>背景图：</label><select name="ad_bg_pic" id="ad_bg_pic" class="ad_canmodi_item">';
				pre_code += '										<option value="0">无背景图</option>';
				pre_code += '										<option value="1">背景图1</option>';
				pre_code += '										<option value="2">背景图2</option>';
				pre_code += '										<option value="3">背景图3</option>';
				pre_code += '										<option value="4">背景图4</option>';
				pre_code += '										<option value="5">背景图5</option>';
				pre_code += '										<option value="6">背景图6</option>';
				pre_code += '										<option value="7">背景图7</option>';
				pre_code += '										<option value="8">背景图8</option>';
				pre_code += '										<option value="9">背景图9</option>';
				pre_code += '										<option value="10">背景图10</option>';
				pre_code += '										<option value="11">背景图11</option>';
				pre_code += '										<option value="12">背景图12</option>';
				pre_code += '										<option value="13">背景图13</option>';
				pre_code += '										<option value="14">背景图14</option>';
				pre_code += '								   </select>';
				pre_code += '		   <img id="ad_bg_pic_show" src="http://" alt="背景图" /></p>';
				pre_code += '		<p><label>转 角 ：</label>';
				pre_code += '				<select name="ad_corner" id="ad_corner" class="ad_canmodi_item">';
				pre_code += '					<option value="0">无圆角</option>';
				pre_code += '					<option value="4">4px</option>';
				pre_code += '					<option value="6">6px</option>';
				pre_code += '					<option value="8">8px</option>';
				pre_code += '					<option value="10">10px</option>';
				pre_code += '				</select>';
				pre_code += '			<img id="ad_corner_show" src="http://" alt="转角" /></p>';
				pre_code += '	</td>';
				pre_code += '	<td>';
				pre_code += '		<p><label>选择状态条：</label><br />';
				pre_code += '			<input type="radio" name="ad_status_icon" class="ad_canmodi_item" id="ad_status_icon0" value="0" /><img src="'+alimama_deluxe_pluginurl+'/images/alimama0.png" alt="Alimama Icon 1" /><br />';
				pre_code += '			<input type="radio" name="ad_status_icon" class="ad_canmodi_item" id="ad_status_icon1" value="1" /><img src="'+alimama_deluxe_pluginurl+'/images/alimama1.png" alt="Alimama Icon 2" /><br />';
				pre_code += '			<input type="radio" name="ad_status_icon" class="ad_canmodi_item" id="ad_status_icon2" value="2" /><img src="'+alimama_deluxe_pluginurl+'/images/alimama2.png" alt="Alimama Icon 3" /></p>';
				pre_code += '	</td>';
				pre_code += '</tr>';
				pre_code += '</table>';
				pre_code += '<div id="alimama-code-div">';
				pre_code += '<label>Javascript 广告代码</label><br />';
				pre_code += '<input id="alimama-deluxe-btn-codeedit1" type="button" value="更改代码（仅高级用户使用）" onclick="jQuery(\'#alimama-deluxe-js-code\').get(0).disabled=false;jQuery(\'#alimama-deluxe-btn-codeedit1\').hide();jQuery(\'#alimama-deluxe-btn-codeedit2\').show();jQuery(\'#alimama-deluxe-btn-codeedit3\').show();" />';
				pre_code += '<input id="alimama-deluxe-btn-codeedit2" type="button" value="识别代码" onclick="load_code_settings(true)" style="display:none" />';
				pre_code += '<input id="alimama-deluxe-btn-codeedit3" type="button" value="关闭高级编辑功能" onclick="jQuery(\'#alimama-deluxe-js-code\').get(0).disabled=true;jQuery(\'#alimama-deluxe-btn-codeedit1\').show();jQuery(\'#alimama-deluxe-btn-codeedit2\').hide();jQuery(\'#alimama-deluxe-btn-codeedit3\').hide();" style="display:none" />';
				pre_code += '<br />';
				pre_code += '<input type="hidden" name="alimama-pid" id="alimama-pid" value="" />';
				pre_code += '<input type="hidden" name="ad_size_code" id="ad_size_code" value="" />';
				pre_code += '<input type="hidden" name="ad_size_width" id="ad_size_width" value="" />';
				pre_code += '<input type="hidden" name="ad_size_height" id="ad_size_height" value="" />';
				pre_code += '<input type="hidden" name="ad_ad_type" id="ad_ad_type" value="" />';
				pre_code += '<textarea style="display:none" name="ad_alimama_deluxe_js_code" id="ad_alimama_deluxe_js_code"></textarea>';
				pre_code += '<textarea id="alimama-deluxe-js-code" name="alimama-deluxe-js-code" style="width:500px;height:300px;" disabled></textarea>';
				pre_code += '</div></div>';
				jQuery(controldiv).html(pre_code);
			
			}
				
				
				
				
				
			function start_alimama_deluxe_preview(previewdiv,controldiv,ad_pid,ad_sizecode,ad_typeid) {
				jQuery(document).ready(function(){
					alimama_deluxe_write_preview_html(previewdiv);
					alimama_deluxe_write_control_html(controldiv);
					jQuery(".ad_color_field").focus(function(){ad_color_onclick("#"+this.id)});
					jQuery(".ad_color_field").each (function(){
						jQuery(this).css('background-color',this.value);
					});
					jQuery("#ad_bg_pic").change(function(){
						jQuery("#ad_bg_pic_show")[0].src=alimama_deluxe_pluginurl+"/images/bg"+this.value+".gif";
						ad_color_schemes_custom();
						ad_gen_code();
					});
					jQuery("#ad_corner").change(function(){
						jQuery("#ad_corner_show")[0].src=alimama_deluxe_pluginurl+"/images/zj"+this.value+".gif";
						ad_color_schemes_custom();
						ad_gen_code();
					});
					jQuery("input[@name='ad_status_icon']").click(function(){this.blur();});
					jQuery("input[@name='ad_status_icon']").change(function(){ 
						ad_color_schemes_custom();
						ad_gen_code();
					});
					var ad_orig_scheme_name = jQuery("input[@name='alimama_deluxe_color_scheme_name']").get(0).value;
					var ad_orig_scheme_detail = jQuery("input[@name='alimama_deluxe_color_scheme_detail']").get(0).value;
					var new_scheme = false;
					try {
						new_scheme = JSON.parse(ad_orig_scheme_detail);
					} catch(e) {
//						alert(e);
						//do nothing
					}
					if (typeof new_scheme == 'object') {
						new_scheme.id = 'usrOrig';
						new_scheme.name = '用户原有设定';
						if (ad_orig_scheme_name == 'custom') ad_orig_scheme_name = 'usrOrig';
						ad_color_schemes.push(new_scheme);
					}
					ad_create_scheme_list();
					if (ad_orig_scheme_name.length > 0) {
						var s = false;
						for (i=0;i<ad_color_schemes.length;i++) {
							if (!ad_color_schemes[i]) continue;
							if (ad_color_schemes[i].id == ad_orig_scheme_name) {
								s=true;
								break;
							}
						}
						if (!s) ad_orig_scheme_name = 'sys1';
					} else ad_orig_scheme_name = 'sys1';
					jQuery("#alimama-pid").get(0).value = ad_pid;
					jQuery('#ad_size_code').get(0).value = ad_sizecode;
					s = ad_size_type(ad_sizecode);
					jQuery('#ad_size_width').get(0).value = s.width;
					jQuery('#ad_size_height').get(0).value = s.height;
					jQuery('#ad_ad_type').get(0).value = ad_typeid;

					setTimeout(function(){load_color_scheme(ad_orig_scheme_name)},1000);
				});
			}	
